package com.hexinfo.dmpro.component.file.transfer.service;

import cn.hutool.extra.ftp.Ftp;
import com.hexinfo.dmpro.component.file.transfer.model.FileTransfer;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPFile;

import java.util.List;

/**
 * @Package com.hexinfo.dmpro.component.file.transfer.service
 * @ClassName FileTransferService
 * @Description 文件传输-业务接口
 * @Author Wang zhihao
 * @Date 2023/9/8 17:47
 * @Version v1.0
 **/
public interface FileTransferService {

    /**
     * @Method createDir
     * @Param fileTransfer
     * @Return boolean
     * @Description 创建目录
     * @Author Wang zhihao
     * @Date 2023/9/8 17:58
     * @Version V1.0
     */
    boolean createDir(FileTransfer fileTransfer);

    /**
     * @Method fileUpload
     * @Param fileTransfer
     * @Return boolean
     * @Description 文件上传
     * @Author Wang zhihao
     * @Date 2023/9/8 17:58
     * @Version V1.0
     */
    boolean fileUpload(FileTransfer fileTransfer);

    /**
     * @Method fileDownload
     * @Param fileTransfer
     * @Return boolean
     * @Description 文件下载
     * @Author Wang zhihao
     * @Date 2023/9/8 17:58
     * @Version V1.0
     */
    boolean fileDownload(FileTransfer fileTransfer);

    /**
     * @Method removeDir
     * @Param fileTransfer
     * @Return boolean
     * @Description 删除目录
     * @Author Wang zhihao
     * @Date 2023/9/8 17:58
     * @Version V1.0
     */
    boolean removeDir(FileTransfer fileTransfer);

    /**
     * @Method getDirSize
     * @Param fileTransfer
     * @Return long
     * @Description 获取目录大小
     * @Author Yin.Yang
     * @Date 2023/12/26 16:32
     * @Version V1.0
     */
    double getDirSize(FileTransfer fileTransfer);

    /**
     * @Method removeDir
     * @Param
     * @param ftpClient
     * @param dir
     * @Return void
     * @Description 删除目录
     * @Author Wang zhihao
     * @Date 2023/11/17 10:25
     * @Version V1.0
     */
    void removeDir(FTPClient ftpClient, String dir);

    /**
     * @Method removeFile
     * @Param
     * @param fileTransfer
     * @Return boolean
     * @Description 删除文件
     * @Author Wang zhihao
     * @Date 2023/9/11 14:25
     * @Version V1.0
     */
    boolean removeFile(FileTransfer fileTransfer);

    /**
     * @Method removeFile
     * @Param
     * @param ftpClient
     * @param filePath
     * @Return boolean
     * @Description 删除文件
     * @Author Wang zhihao
     * @Date 2023/11/17 10:25
     * @Version V1.0
     */
    boolean removeFile(FTPClient ftpClient, String filePath);

    /**
     * @Method fileTransfer
     * @Param fileTransfer
     * @Return boolean
     * @Description 文件备份
     * @Author Wang zhihao
     * @Date 2023/9/8 17:59
     * @Version V1.0
     */
    boolean fileTransfer(FileTransfer fileTransfer);

    /**
     * @Method isFolderExists
     * @Param
     * @param fileTransfer
     * @Return boolean
     * @Description 检测文件目录是否存在
     * @Author Wang zhihao
     * @Date 2023/10/18 14:29
     * @Version V1.0
     */
    boolean isFolderExists(FileTransfer fileTransfer);

    /**
     * @Method isFileExists
     * @Param
     * @param fileTransfer
     * @Return boolean
     * @Description 检测文件是否存在
     * @Author Wang zhihao
     * @Date 2023/10/18 14:30
     * @Version V1.0
     */
    boolean isFileExists(FileTransfer fileTransfer);


    /**
     * @Method fileTransferUseClient
     * @Param
     * @param fileTransfer
     * @Return boolean
     * @Description 用入参FTPClient备份文件
     * @Author Wang zhihao
     * @Date 2023/10/19 14:11
     * @Version V1.0
     */
    void fileRenameUseClient(FileTransfer fileTransfer);

    /**
     * @Method fileRename
     * @Param
     * @param ftpClient
     * @param originalFilePath
     * @param newFilePath
     * @Return void
     * @Description 重命名文件
     * @Author Wang zhihao
     * @Date 2023/10/19 19:33
     * @Version V1.0
     */
    void fileRename(FTPClient ftpClient, String originalFilePath, String newFilePath);

    /**
     * @Method fileBackup
     * @Param
     * @param ftpClient
     * @param originalFilePath
     * @param newFileDir
     * @param fileName
     * @Return void
     * @Description 重命名文件
     * @Author Wang zhihao
     * @Date 2023/11/17 10:25
     * @Version V1.0
     */
    void fileBackup(FTPClient ftpClient, String originalFilePath, String newFileDir, String fileName);

    /**
     * @Method createDirUseClient
     * @Param
     * @param fileTransfer
     * @Return boolean
     * @Description 用入参FTPClient创建文件目录
     * @Author Wang zhihao
     * @Date 2023/10/19 13:47
     * @Version V1.0
     */
    void createDirUseClient(FileTransfer fileTransfer);

    /**
     * @Method isFolderExistsUseClient
     * @Param
     * @param fileTransfer
     * @Return boolean
     * @Description 用入参FTPClient检测文件目录是否存在
     * @Author Wang zhihao
     * @Date 2023/10/19 13:43
     * @Version V1.0
     */
    boolean isFolderExistsUseClient(FileTransfer fileTransfer);

    /**
     * @Method isFileExistsUseClient
     * @Param
     * @param fileTransfer
     * @Return boolean
     * @Description 用入参FTPClient检测文件是否存在
     * @Author Wang zhihao
     * @Date 2023/10/19 13:43
     * @Version V1.0
     */
    boolean isFileExistsUseClient(FileTransfer fileTransfer);

    /**
     * @Method isFileExistsUseClient
     * @Param
     * @param ftpClient
     * @param remoteFilePath
     * @Return boolean
     * @Description 检测文件是否存在
     * @Author Wang zhihao
     * @Date 2023/11/17 10:25
     * @Version V1.0
     */
    boolean isFileExistsUseClient(FTPClient ftpClient, String remoteFilePath);

    /**
     * @Method fileUploadWithCreate
     * @Param
     * @param fileTransfer
     * @Return void
     * @Description 用入参FTPClient上传文件(若目录不存在会创建)
     * @Author Wang zhihao
     * @Date 2023/10/19 14:08
     * @Version V1.0
     */
    void fileUploadUseClient(FileTransfer fileTransfer);

    /**
     * @Method fileUploadUseClient
     * @Param
     * @param ftpClient
     * @param rootAbsoluteDir
     * @param fileAbsolutePath
     * @param fileName
     * @Return void
     * @Description 上传文件(若目录不存在会创建)
     * @Author Wang zhihao
     * @Date 2023/11/17 10:25
     * @Version V1.0
     */
    void fileUploadUseClient(FTPClient ftpClient, String rootAbsoluteDir, String fileAbsolutePath, String fileName);

    /**
     * @Method getFileByDir
     * @Param
     * @param ftpClient
     * @param fileDir
     * @Return java.util.List<java.lang.String>
     * @Description 读取目录下的文件信息
     * @Author Wang zhihao
     * @Date 2023/10/19 17:23
     * @Version V1.0
     */
    List<String> getFileByDir(FTPClient ftpClient, String fileDir);

    /*
     * @Method: listFiles <br>
     * @Param: [fileTransfer] <br>
     * @Return: java.util.List<java.lang.String> <br>
     * @Description：获取指定目录下所有文件<br>
     * @Author： wz.li<br>
     * @Date： 2023/11/9 17:43 <br>
     * @Version： V2.0.2<br>
     */
    List<FTPFile> listFiles(Ftp ftpClient, String fileDir) throws Exception;

    /*
     * @Method: readFile <br>
     * @Param: [fileTransfer] <br>
     * @Return: java.lang.String <br>
     * @Description：读取远程文件内容<br>
     * @Author： wz.li<br>
     * @Date： 2023/11/22 14:16 <br>
     * @Version： V2.0.2<br>
     */
    String readFile(FileTransfer fileTransfer);
}
